import logging
import os
def log(name):
    logger = ''
    logger = logging.getLogger(name)
    logger.setLevel(level = logging.DEBUG)
    filePath = os.path.join(os.getenv('userprofile'),'tsp-all.log')
    handler = logging.FileHandler(filePath, encoding= 'utf-8')
    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter('%(asctime)s %(filename)s [line:%(lineno)2d]-%(funcName)s %(levelname)s %(message)s')
    handler.setFormatter(formatter)

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    console.setFormatter(formatter)

    logger.addHandler(handler)
    logger.addHandler(console)
    return logger

if __name__ == "__main__":
    logger = log(__name__)
    logger.info("creating an instance of subModule.subModuleClass")
    # a = subModule.SubModuleClass()
    logger.info("calling subModule.subModuleClass.doSomething")
    # a.doSomething()
    logger.info("done with  subModule.subModuleClass.doSomething")
    logger.info("calling subModule.some_function")
    # subModule.som_function()
    logger.info("done with subModule.some_function")
    logger.info("Start logger.info log")
    logger.debug("Do something")
    logger.warning("Something maybe fail.")